<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-btn+.layui-btn{
            margin-left: 0;
        }
        .layui-table td, .layui-table th
        {
            min-width: 50px !important;
        }
        .layui-table-cell{padding: 0 3px !important;}
        
        .layui-table td,.layui-table th,.layui-table tr,.layui-table,.layui-table thead,.layui-table tfoot,.layui-table-header,.layui-table-total{border-color:#000 !important}
        
        
        .layui-btn-xs {height: 22px !important;line-height: 22px !important;padding: 0 5px !important;font-size: 12px;}
        /*table thead .layui-table-col-special:nth-child(2n){background-color:#ddebf7}
        table thead .layui-table-col-special:nth-child(2n-1){background:#fce4d6}*/
        .layui-table-box .layui-table-body .layui-table tr td:nth-child(n+1){background-color:#F0E3AB}
        .layui-table-box .layui-table-body .layui-table tr td:nth-child(n+5){background-color:#ddebf7}
        .layui-table-box .layui-table-body .layui-table tr td:nth-child(n+15){background-color:#fce4d6}
        .layui-table-box .layui-table-body .layui-table tr td:nth-child(n+24){background-color:#ddebf7}
        .layui-table-box .layui-table-body .layui-table tr td:nth-child(15){background-color:#F0E3AB}
        
        .layui-table-total  .layui-table tr td:nth-child(n+1){background-color:#F0E3AB}
        .layui-table-total  .layui-table tr td:nth-child(n+5){background-color:#ddebf7}
        .layui-table-total  .layui-table tr td:nth-child(n+15){background-color:#fce4d6}
        .layui-table-total  .layui-table tr td:nth-child(n+24){background-color:#ddebf7}
        .layui-table-total  .layui-table tr td:nth-child(n+34){background-color:#F0E3AB}
        
        .layui-table-box .layui-table-header .layui-table tr:nth-child(1) th:nth-child(n+1){background-color:#F0E3AB}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(2) th:nth-child(n+1){background-color:#F0E3AB}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(1) th:nth-child(4){background-color:#ddebf7}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(1) th:nth-child(5){background-color:#fce4d6}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(1) th:nth-child(6){background-color:#ddebf7}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(2) th:nth-child(n+3){background-color:#ddebf7}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(2) th:nth-child(n+13){background-color:#fce4d6}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(2) th:nth-child(n+22){background-color:#ddebf7}
        .layui-table-box .layui-table-header .layui-table tr:nth-child(2) th:nth-child(13){background-color:#F0E3AB}
        
        .layui-btn-container{display:inline}
        .table-title{display:inline;font-size: 18px; margin-left: 30%;}
    </style>
  </head>
  
  <body> 
    <div class="x-body x-admin" style="padding:0 10px">
      <xblock style="">
        <div class="layui-card-body" style="padding-left: 0;float:left;padding-left:20px;padding-top:0;">
          <form class="layui-form layui-col-space5" action="" method="get">
            
          </form>
        </div>
      </xblock>
      <div class="layui-table-body layui-table-main" style="width: 100%;min-height:0;">
        <table class="layui-table layui-form" lay-filter="performance" id="performance"> </table>
      </div>
    </div>
    <script type="text/html" id="checkStatusHtml">
      {{ d.check_status == 1 ? '<span class="layui-badge layui-bg-green"><i class="layui-icon layui-icon-ok"></i></span>' : '<a title="核对" class="layui-btn layui-btn-primary layui-btn-xs " lay-filter="check" lay-submit="" lay-id="'+d.id+'" href="javascript:;"><i class="layui-icon">核对</i></a>' }}
    </script>
     <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
    <script type="text/html" id="barDemo">
    {{d.status == 0 && d.admin_id == {:session('uid','','admin')}?'<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">申报/修改</a>':'' }}
    {{d.status == 0 && ( {:session('group_id','','admin')} == 5||{:session('group_id','','admin')} == 1)?'未申报':''}}
    {if condition="session('group_id','','admin') != 1"}
    {{d.status == 1 ?'待审核':'' }}
    {else}
    {{d.status == 1 ?'<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="check">审核</a>':'' }}
    {/if}
    {{d.status == 2 ?'<a class="layui-btn-primary layui-border-green" lay-event="check" title="点击可修改">通过</a>':'' }}
    </script>
    <script type="text/html" id="toolbarDemo">
      <div class="layui-btn-container">
        <button class="layui-btn layui-btn-normal" id="batch_check">批量审核通过</button>
      </div>
      <div class="table-title">
            赛事直播收益待审核列表
      </div>
    </script>
    <script type="text/html" id="rank">
    {{d.LAY_TABLE_INDEX+1}}
    </script>
        
    <script>
      layui.use(['form','layer','jquery','table','util'], function(){
        form = layui.form,
        layer = layui.layer
        ,$ = layui.jquery
        ,table = layui.table
        ,util = layui.util;
        
        form.on('select(month)', function(data){
            window.location.href="?month="+data.value
        });
        
        table.render({
            elem: '#performance'
            ,height: $(window).height()-50
            ,url:'{:url('admin/performance/checkList')}?month={$month}'
            ,toolbar: '#toolbarDemo' 
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,limit: 500
            ,title: '业绩明细'
            ,totalRow: true
            ,cols: [
                [
                {type:'checkbox',fixed: 'left',rowspan:2,field:'id',},
                {align: "center", title:'序号', width: 70, sort: false, fixed: 'left', templet: '#rank', totalRowText: '合计',rowspan:2 },
                
                {align: "center", title:'', colspan:2 ,style:"background-color:#ddebf7;",align:'right'},
                {align: "center", title:"后台收益" ,colspan:11 ,style:"background:#fce4d6"},
                {align: "center", title:"客户收益" ,colspan:9,style:"background:#ddebf7"},
                {align: "center", title:"业务员收益" ,colspan:9 ,style:"background:#fce4d6"},
                
                {align: "center",field:'salesman_final_performance', width:80,title:"业绩",totalRow: true,fixed: 'right',},
                {align: "center", fixed: 'right', width:100,title:"操作",  toolbar: '#barDemo',rowspan:2},
                ],
                [
                {align: "center",field:'admin_name', fixed: 'left', width:70, sort: false,title:"营销"},
                {align: "center",field:'title',  fixed: 'left', width:200, title:"活动名称" ,unresize1:true},
                //{align: "center",field:'address', width:150,title:"活动地区"},
                {align: "center",field:'vote_date', width:80,title:"投票时间"},
                //{align: "center",field:'salesman_radio', width:90,title:"公司比例"},
                
                {align: "center",field:'total_income', width:80,title:"后台收益" ,totalRow: true},
                {align: "center",field:'refund_income', width:80,title:"投错票"},
                {align: "center",field:'reduce_income', width:80,title:"* * *",totalRow: true},
                
                {align: "center",field:'live_fee', width:60,title:"直播费",totalRow: true},
                {align: "center",field:'plive_fee', width:80,title:"照片直播",totalRow: true},
                {align: "center",field:'gift_fee', width:60,title:"礼品费",totalRow: true},
                {align: "center",field:'travel_fee', width:60,title:"差旅费"},
                {align: "center",field:'other_fee', width:80,title:"其它费用"},
                
                {align: "center",field:'real_income', width:80,title:"实际收益",totalRow: true},

                {align: "center",field:'ratio', width:80,title:"分成比例"},
                {align: "center",field:'client_income', width:80,title:"客户收益",totalRow: true},
                {align: "center",field:'client_sxfee_radio', width:100,title:"手续费点位"},
                {align: "center",field:'client_charges', width:60,title:"手续费",totalRow: true},
                {align: "center",field:'client_live_fee', width:60,title:"直播费"},
                {align: "center",field:'client_plive_fee', width:80,title:"照片直播"},
                {align: "center",field:'client_gift_fee', width:60,title:"礼品费",totalRow: true},
                {align: "center",field:'client_travel_fee', width:60,title:"差旅费"},
                {align: "center",field:'client_other_fee', width:80,title:"其它费用"},
                {align: "center",field:'client_final_income', width:80,title:"实际收益",totalRow: true},
                
                {align: "center",field:'salesman_performance', width:80,title:"赛事业绩",totalRow: true},
                {align: "center",field:'salesman_charges', width:60,title:"手续费",totalRow: true},
                {align: "center",field:'salesman_recommend_fee', width:60,title:"介绍费"},
                {align: "center",field:'salesman_live_fee', width:60,title:"直播费",totalRow: true},
                {align: "center",field:'salesman_plive_fee', width:80,title:"照片直播",totalRow: true},
                {align: "center",field:'salesman_gift_fee', width:60,title:"礼品费",totalRow: true},
                {align: "center",field:'salesman_travel_fee', width:60,title:"差旅费"},
                {align: "center",field:'salesman_other_fee', width:80,title:"其它费用"},
                {align: "center",field:'salesman_other_performance', width:80,title:"其它业绩"},
              
            ]]
            ,page: false
        });

        table.on('edit(performance)', function(obj){
            var value = obj.value 
            ,data = obj.data 
            ,field = obj.field;
            console.log(obj);
            
        });

        table.on('tool(performance)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
              layer.confirm('确认要删除吗？',function(index){
                  $.ajax({
                    type:'POST',
                    dataType:'json',
                    data:{id:data.id},
                    url:"",
                    success:function(o){
                      layer.msg(o.msg,{icon:o.icon,time:1000});
                      obj.del();
                    }
                  });
              });
            } else if(obj.event == 'edit'){
                x_admin_show('查看详情','{:url('performance/report')}/?id='+data.id,true)
            } else if(obj.event == 'check'){
                x_admin_show('查看详情','{:url('performance/report')}/id/'+data.id,true)
            /*
              layer.confirm('确认要审核此条吗？',function(index){
                  $.ajax({
                    type:'POST',
                    dataType:'json',
                    data:{id:data.id},
                    url:"{:url('performance/check')}",
                    success:function(o){
                        layer.msg(o.msg,{icon:o.icon,time:1000});
                        if(o.code == 1)
                            window.location.reload();
                    }
                  });
              });*/
            }
        });
        
        $('#batch_check').click(function(){
            
            var check_arr = table.checkStatus('performance');
            if(check_arr.data.length>0)
            {
                layer.confirm('确定批量审核已勾选吗？', {
                    btn: ['确定','取消']
                }, function(){
                    var ids = '';
                    $.each(check_arr.data, function(index, value) {
                        if(value.id && value.id != 'undefined')
                            ids += value.id+','
                    });
                    var reg=/,$/gi;
                    ids = ids.replace(reg,"");
                    $.post('/admin.php/Performance/check',{id:ids},function(data){
                        layer.alert(data.msg, {icon: data.icon},function(){
                            location.reload();
                        });  
                    },'json')
                }, function(){
                    
                });

            }
        })
        

        
      });

    </script>
  </body>

</html>